<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'index.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

<style type="text/css">


table {
	border: 1px red solid;
	border-collapse: collapse;
}
table tr {
	border: 1px red solid;
}
table tr td {
	border: 1px red solid;
}

</style>

</head>

<body>
	This is my JSP page.
	<br>
	<form action="Hgx.do" method="get">
		<input type="text" name="method" value="HGX"> <input
			type="text" name="a" value="a"> <input type="submit"
			value="提交">
	</form>
	<button onclick="deploy();">流程部署</button>
	<button onclick="lastVersionlist();">查询所有流程</button>
	</br>
	<div>
		<table id="proTalbe" style="width: 100%;text-align: center;">
			
		</table>
	</div>
	</br>
	<div>
		<table id="proTalbeVersion" style="width: 100%;text-align: center;">
			
		</table>
	</div>
</body>
<script type="text/javascript" src="static/JS/jquery.js"></script>
<script type="text/javascript">
	$(function() {
		console.log("1");
	});
	/******流程部署*********/
	function deploy() {
		$.ajax({
			url : "test/process.do",
			data : "method=deploy",
			dataType : "json",
			success : function(data) {
				console.log(data);
			}
		});
	}

	/*********查询所有流程定义***************/

	function lastVersionlist() {
		$.ajax({
			url : "test/process.do",
			data : "method=lastVersionlist",
			dataType : "json",
			success : function(data) {
				if (data.status == "SUCCESS") {
					var arrPro = data.data;
					if(arrPro.length > 0){
						var ptbody = "";
						for(var i = 0 ; i < arrPro.length ; i++){
							ptbody += "<tr onclick='processDefinitionVersionlist(\""+arrPro[i].key+"\");'><td>"+arrPro[i].id+"</td><td>"+arrPro[i].name+"</td><td>"+arrPro[i].key+"</td><td>"+arrPro[i].version+"</td></tr>";
						}
						$("#proTalbe").append(ptbody);
					}
				}
			}
		});
	}

	/*********查询所有流历史版本***************/

	function processDefinitionVersionlist(key) {
		$.ajax({
			url : "test/process.do",
			data : {
				method:"findProcessDefinitionVersionAll",
				key : key
			},
			dataType : "json",
			success : function(data) {
				if (data.status == "SUCCESS") {
					var arrPro = data.data;
					if(arrPro.length > 0){
						var ptbody = "";
						for(var i = 0 ; i < arrPro.length ; i++){
							ptbody += "<tr><td>"+arrPro[i].id+"</td><td>"+arrPro[i].name+"</td><td>"+arrPro[i].key+"</td><td>"+arrPro[i].version+"</td></tr>";
						}
						$("#proTalbeVersion").append(ptbody);
					}
				}
			}
		});
	}
</script>
</html>
